package com.zh.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zh.common.QueryPageParam;
import com.zh.common.Result;
import com.zh.entity.GoodsType;
import com.zh.service.GoodsTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zh
 * @since 2025-04-06
 */
@RestController
@RequestMapping("/goodsType")
@Slf4j
public class GoodsTypeController {
    @Autowired
    private GoodsTypeService goodsTypeService;

    @PostMapping("/save")
    public boolean save(@RequestBody GoodsType goodsType) {
        return goodsTypeService.save(goodsType);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody GoodsType goodsType) {
        return goodsTypeService.updateById(goodsType);
    }

    @DeleteMapping("/delete")
    public boolean delete(@RequestParam Integer id) {
        return goodsTypeService.removeById(id);
    }

    /**
     * 分页查询
     */

    @PostMapping("/listPage")
    public Result listPage(@RequestBody QueryPageParam queryPageParam) {
        return goodsTypeService.listPage(queryPageParam);
    }

    /**
     * 查询所有
     */
    @PostMapping("/list")
    public Result list() {
        return Result.success(goodsTypeService.list(),0L);
    }

}
